
#include <stdio.h>
#include "sqlist.h"

int main ()
{
    SeqList plist;
    POSITION i;

    int num;
    char operator;
    ELEMTYPE data;
    
    scanf("%d", &num);
    
    while (num > 0)
    {
        //while (scanf("%c", &operator) == EOF);
        while ((operator = getchar()) == '\n'); 

        switch (operator)
        {
            case 'C': 
                     scanf("%d", &data);
                     plist = createSeqList(data);
                     if (plist == NULL)
                     {
                         printf("ERROR!!\n");
                         return -1;
                     }
                     break;
            case 'W':
                     destroySeqList(plist);
                     break;
            case 'P':
                     printSeqList(plist);
                     break;
            case 'L':
                     printf("%d\n", lengthSeqList(plist));
                     break;
            case 'E':
                     scanf("%d", &i);
                     getVertexSeqList(plist, i, &data);
                     printf("%d\n", data);
                     break;
            case 'F':
                     scanf("%d", &data);
                     i = locateVertexSeqList(plist, data);
                     if (i != -1)
                     {
                         printf("%d\n", i);
                     }
                     break;
            case 'B':
                     scanf("%d%d", &i, &data);
                     insertPreSeqList(plist, i, data);
                     break;
            case 'A':
                     scanf("%d%d", &i, &data);
                     insertPostSeqList(plist, i, data);
                     break;
            case 'D':
                     scanf("%d", &data);
                     deleteElemSeqList(plist, data);
                     break;
            case 'S':
                     scanf("%d", &i);
                     deleteVertexSeqList(plist, i);
                     break;
            case 'R':
                     scanf("%d", &data);
                     appendElemSeqList(plist, data);
                     break;
        }
        num--;
    }

/*
    plist = createSeqList(15);
    
    if (plist != NULL)
    {
        printSeqList(plist);
    }
    
    i = locateVertexSeqList(plist, 0);
    if (i != -1)
    {
        printf("0 is in the %dth of the list\n", i);
    }

    insertPreSeqList(plist, 1, -1);
    insertPostSeqList(plist, 0, -2);
    printSeqList(plist);
    deleteElemSeqList(plist, 14);
    printSeqList(plist);
    destroySeqList(plist);
*/
    return 0;
}
